﻿using Microsoft.Extensions.DependencyInjection;

namespace Common.Extensions;

public static class ServiceProviderExtensions
{
    public static T GetServiceProvider<T>(this IServiceProvider serviceProvider) where T : class
    {
        using var scope = serviceProvider.CreateScope();
        return scope.ServiceProvider.GetRequiredService<T>();
    }
}
